feat(exec): detect compiler activity during process startup#119
feat(exec): detect compiler activity during process startup#119moshloop wants to merge 1 commit into
Conversation
Add compiler and linker detection to distinguish compilation phase from startup phase. Introduces StatusCompiling to track when build tools are actively running, preventing premature promotion to StatusRunning. The watchPorts function now accepts a compilationDetector callback and manages three startup states: compiling → starting → running. Compiler activity resets the grace period timer, allowing long builds to complete without timing out. A detected port immediately promotes to running regardless of compilation state. Refs: compiler detection for improved startup lifecycle management
WalkthroughAdds a ChangesCompiler detection and watchPorts state machine
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Gavel summary
Totals: 1995 passed · 1 failed · 63 skipped · 1m57s Failing testsgithub.com/flanksource/clicky — TestPromptMultiSelectConfirmsSelections |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@exec/compiler.go`:
- Around line 34-50: The detectCompilers function silently ignores all errors
from gopsutil probes (gops.NewProcess, proc.Name, proc.Exe, proc.CmdlineSlice)
by using continue statements and always returns nil error regardless of
inspection failures. Track errors during the iteration through collectPids
results, and when compiler detection has no visibility into the process tree
(all probes fail), return an appropriate error instead of nil so callers can
distinguish between "no compilers found" and "couldn't inspect processes". This
ensures the caller doesn't prematurely advance startup state when inspection
failures occur.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 21e3e8df-63fe-40e8-b4b9-6c478b1c7cd0
📒 Files selected for processing (4)
exec/compiler.goexec/supervise_loop.goexec/supervised.goexec/supervised_test.go
| func detectCompilers(root int32) (bool, error) { | ||
| for _, pid := range collectPids(root) { | ||
| proc, err := gops.NewProcess(pid) | ||
| if err != nil { | ||
| continue | ||
| } | ||
| if name, err := proc.Name(); err == nil && isCompilerExecutable(name) { | ||
| return true, nil | ||
| } | ||
| if exe, err := proc.Exe(); err == nil && isCompilerExecutable(exe) { | ||
| return true, nil | ||
| } | ||
| if args, err := proc.CmdlineSlice(); err == nil && isCompilerCommandLine(args) { | ||
| return true, nil | ||
| } | ||
| } | ||
| return false, nil |
There was a problem hiding this comment.
Surface probe failures when compiler detection has no visibility.
detectCompilers currently swallows all gopsutil probe errors and always returns nil error. When inspection fails across the tree, the caller treats that as “not compiling”, which can advance startup state prematurely.
Proposed fix
func detectCompilers(root int32) (bool, error) {
+ var firstErr error
+ visible := false
for _, pid := range collectPids(root) {
proc, err := gops.NewProcess(pid)
if err != nil {
+ if firstErr == nil {
+ firstErr = err
+ }
continue
}
- if name, err := proc.Name(); err == nil && isCompilerExecutable(name) {
+ if name, err := proc.Name(); err == nil {
+ visible = true
+ if isCompilerExecutable(name) {
+ return true, nil
+ }
+ } else if firstErr == nil {
+ firstErr = err
+ }
+ if exe, err := proc.Exe(); err == nil {
+ visible = true
+ if isCompilerExecutable(exe) {
+ return true, nil
+ }
+ } else if firstErr == nil {
+ firstErr = err
+ }
+ if args, err := proc.CmdlineSlice(); err == nil {
+ visible = true
+ if isCompilerCommandLine(args) {
+ return true, nil
+ }
+ } else if firstErr == nil {
+ firstErr = err
+ }
- return true, nil
- }
- if exe, err := proc.Exe(); err == nil && isCompilerExecutable(exe) {
- return true, nil
- }
- if args, err := proc.CmdlineSlice(); err == nil && isCompilerCommandLine(args) {
- return true, nil
- }
}
+ if !visible && firstErr != nil {
+ return false, firstErr
+ }
return false, nil
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| func detectCompilers(root int32) (bool, error) { | |
| for _, pid := range collectPids(root) { | |
| proc, err := gops.NewProcess(pid) | |
| if err != nil { | |
| continue | |
| } | |
| if name, err := proc.Name(); err == nil && isCompilerExecutable(name) { | |
| return true, nil | |
| } | |
| if exe, err := proc.Exe(); err == nil && isCompilerExecutable(exe) { | |
| return true, nil | |
| } | |
| if args, err := proc.CmdlineSlice(); err == nil && isCompilerCommandLine(args) { | |
| return true, nil | |
| } | |
| } | |
| return false, nil | |
| func detectCompilers(root int32) (bool, error) { | |
| var firstErr error | |
| visible := false | |
| for _, pid := range collectPids(root) { | |
| proc, err := gops.NewProcess(pid) | |
| if err != nil { | |
| if firstErr == nil { | |
| firstErr = err | |
| } | |
| continue | |
| } | |
| if name, err := proc.Name(); err == nil { | |
| visible = true | |
| if isCompilerExecutable(name) { | |
| return true, nil | |
| } | |
| } else if firstErr == nil { | |
| firstErr = err | |
| } | |
| if exe, err := proc.Exe(); err == nil { | |
| visible = true | |
| if isCompilerExecutable(exe) { | |
| return true, nil | |
| } | |
| } else if firstErr == nil { | |
| firstErr = err | |
| } | |
| if args, err := proc.CmdlineSlice(); err == nil { | |
| visible = true | |
| if isCompilerCommandLine(args) { | |
| return true, nil | |
| } | |
| } else if firstErr == nil { | |
| firstErr = err | |
| } | |
| } | |
| if !visible && firstErr != nil { | |
| return false, firstErr | |
| } | |
| return false, nil | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@exec/compiler.go` around lines 34 - 50, The detectCompilers function silently
ignores all errors from gopsutil probes (gops.NewProcess, proc.Name, proc.Exe,
proc.CmdlineSlice) by using continue statements and always returns nil error
regardless of inspection failures. Track errors during the iteration through
collectPids results, and when compiler detection has no visibility into the
process tree (all probes fail), return an appropriate error instead of nil so
callers can distinguish between "no compilers found" and "couldn't inspect
processes". This ensures the caller doesn't prematurely advance startup state
when inspection failures occur.
What
StatusCompilingto track when build tools are actively runningwatchPortsfunction to acceptcompilationDetectorcallbackWhy
StatusRunningduring buildsNotes
Summary by CodeRabbit